package com.how.warlock.engine;

import static org.lwjgl.opengl.GL11.*;

import com.how.warlock.Game;
import com.how.warlock.player.Camera;


public class Grid {
	
	Game game;
	
	public Grid(Game game){
		this.game = game;
	}
	
	public void draw(){
		int tileSize = com.how.warlock.tilemap.TileMap.tileSize;
		
		glColor4f(1.0f,1.0f,0.0f,0.2f);
		glDisable(GL_TEXTURE_2D);
		
		for (int i=-1 + Camera.getX()/tileSize; i<(game.getWidth()+Camera.getX())/tileSize+1; i++) {
			glPushMatrix();
			glTranslatef(i*tileSize-Camera.getX(),0,0);
			
			glBegin(GL_QUADS);
			{
				glVertex2i(0,0);
				glVertex2i(1,0);
				glVertex2i(1,game.getHeight());
				glVertex2i(0,game.getHeight());
			}
			glEnd();
			glPopMatrix();
		}
		
		for (int i=-1 + Camera.getY()/tileSize; i<game.getHeight()+Camera.getY()/tileSize+1; i++) {
			glPushMatrix();
			glTranslatef(0,i*tileSize-Camera.getY(),0);
			
			glBegin(GL_QUADS);
			{
				glVertex2i(0,0);
				glVertex2i(0,1);
				glVertex2i(game.getWidth(),1);
				glVertex2i(game.getWidth(),0);
			}
			glEnd();
			glPopMatrix();
		}
	}
}
